import { createRouter, createWebHistory } from 'vue-router'
import Login from '../views/Login.vue'
import Layout from '../views/Layout.vue'
import UserManagement from '../views/UserManagement.vue'
import DictionaryManagement from '../views/DictionaryManagement.vue'
import CustomerManagement from '../views/CustomerManagement.vue'
import InteractionRecordManagement from '../views/InteractionRecordManagement.vue'
import AnalysisManagement from '../views/AnalysisManagement.vue'
import MenuManagement from '../views/MenuManagement.vue'
import RoleManagement from '../views/RoleManagement.vue'
import ProductPublish from '../views/ProductPublish.vue'
import SequenceManagement from '../views/SequenceManagement.vue'

const routes = [
  {
    path: '/',
    redirect: '/product/publish'
  },
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: 'product/publish',
        name: 'ProductPublish',
        component: ProductPublish
      },
      {
        path: 'sequence/management',
        name: 'SequenceManagement',
        component: SequenceManagement
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

// 已移除登录验证

// Set page title
router.afterEach((to) => {
  const titleMap = {
    '/product/publish': '商品发布',
    '/sequence/management': '序列号管理'
  }
  document.title = titleMap[to.path] || '系统管理'
})

export default router